package com.ruoyi.project.oms.paeaAuOperAuditor.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.oms.paeaAuOperAuditor.domain.PaeaAuOperAuditor;
import com.ruoyi.project.oms.paeaAuOperAuditor.service.IPaeaAuOperAuditorService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 质检流水下发差错统计Controller
 *
 * @author px
 * @date 2020-04-18
 */
@Controller
@RequestMapping("/oms/paeaAuOperAuditor")
public class PaeaAuOperAuditorController extends BaseController
{
    private String prefix = "oms/paeaAuOperAuditor";

    @Autowired
    private IPaeaAuOperAuditorService paeaAuOperAuditorService;

    @RequiresPermissions("oms:paeaAuOperAuditor:view")
    @GetMapping()
    public String paeaAuOperAuditor()
    {
        return prefix + "/paeaAuOperAuditor";
    }

    /**
     * 查询质检流水下发差错统计列表
     */
    @RequiresPermissions("oms:paeaAuOperAuditor:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaAuOperAuditor paeaAuOperAuditor)
    {
        startPage();
        List<PaeaAuOperAuditor> list = paeaAuOperAuditorService.list(new QueryWrapper<>(paeaAuOperAuditor));
        return getDataTable(list);
    }

    /**
     * 导出质检流水下发差错统计列表
     */
    @RequiresPermissions("oms:paeaAuOperAuditor:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaAuOperAuditor paeaAuOperAuditor)
    {
        List<PaeaAuOperAuditor> list = paeaAuOperAuditorService.list(new QueryWrapper<>(paeaAuOperAuditor));
        ExcelUtil<PaeaAuOperAuditor> util = new ExcelUtil<PaeaAuOperAuditor>(PaeaAuOperAuditor.class);
        return util.exportExcel(list, "paeaAuOperAuditor");
    }

    /**
     * 新增质检流水下发差错统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存质检流水下发差错统计
     */
    @RequiresPermissions("oms:paeaAuOperAuditor:add")
    @Log(title = "质检流水下发差错统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaAuOperAuditor paeaAuOperAuditor)
    {
        return toAjax(paeaAuOperAuditorService.saveOrUpdate(paeaAuOperAuditor));
    }

    /**
     * 修改质检流水下发差错统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaAuOperAuditor paeaAuOperAuditor = paeaAuOperAuditorService.getById(id);
        mmap.put("paeaAuOperAuditor", paeaAuOperAuditor);
        return prefix + "/edit";
    }

    /**
     * 修改保存质检流水下发差错统计
     */
    @RequiresPermissions("oms:paeaAuOperAuditor:edit")
    @Log(title = "质检流水下发差错统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaAuOperAuditor paeaAuOperAuditor)
    {
        return toAjax(paeaAuOperAuditorService.saveOrUpdate(paeaAuOperAuditor));
    }

    /**
     * 删除质检流水下发差错统计
     */
    @RequiresPermissions("oms:paeaAuOperAuditor:remove")
    @Log(title = "质检流水下发差错统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaAuOperAuditorService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
